<?php
/**
 * 解析已收到库存-数据入库 (已作废)
 *（Logic）
 */
namespace App\Logic\Amazon\Api\Parse;

use App\Models\Amazon\AmazonSkuName;
use App\Models\Amazon\FbaFulfillmentInventory;
class GetFbaFulfillmentInventoryReceiptsData
{
    public static function exe($lines,$accountId){

        die('stop!');

        /*if(!$accountId)return 2;
        if(!is_array($lines))return 2;
        $i = 0;
        $count = 0;
        try{
            foreach($lines as $line){
                $flag = self::_addFbaFulfillment($line);
                $flag && $count++;
                $i++;
            }
        }catch (\Exception $e){
            report($e);
        }
        return $i == $count ? 1 : 2;*/
    }

    /**
     * @param $line
     * @return bool
     */
    /*private static function _addFbaFulfillment($line){
        AmazonSkuName::addName($line['sku'],$line['product-name']);
        $receivedDate = gmdate('Y-m-d H:i:s',strtotime($line['received-date']));
        $item = [
            'received_date' => $receivedDate,
            'fnsku' => $line['fnsku'],
            'seller_sku' => $line['sku'],
            'quantity' => $line['quantity'],
            'fba_shipment_id' => $line['fba-shipment-id'],
            'fulfillment_center_id' => $line['fulfillment-center-id'],
        ];
        $count = FbaFulfillmentInventory::query()
            ->where('received_date',$receivedDate)
            ->where('seller_sku',$line['sku'])
            ->where('quantity',$line['quantity'])
            ->where('fba_shipment_id',$line['fba-shipment-id'])
            ->where('fulfillment_center_id',$line['fulfillment-center-id'])
            ->count();
        if($count > 0)return true;
        $re = FbaFulfillmentInventory::query()->create($item);
        return !$re ? false : true;
    }*/

}
